<div class="main-content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <form class="card-header border-bottom row form-inline" method="GET" action="/<?php echo site_url("subs") ?>">
                        <h4 class="card-title col-lg-2 col-md-6 col-xs-12">公众号</h4>
                        <div class="col-lg-10 col-md-6 col-xs-12">
                            <label class="sr-only" for="id">公众号id</label>
                            <input type="text" class="form-control mb-2 mr-sm-2" id="sub_id" name="sub_id" placeholder="公众号id" value="<?php if($search){ echo $search["sub_id"];} ?>">
                            <label class="sr-only" for="name">公众号名称</label>
                            <input type="text" class="form-control mb-2 mr-sm-2" id="sub_name" name="sub_name" placeholder="公众号名称" value="<?php if($search){ echo $search["sub_name"];} ?>">
                            <button type="submit" class="btn btn-primary mb-2">查询</button>
                            <button type="button" class="btn btn-common mb-2" data-toggle="modal" data-target=".modal-create-subscription">添加</button>
                        </div>
                    </form>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered mb-0">
                                <thead>
                                <tr>
                                    <th>#</th>
                                    <th>公众号id</th>
                                    <th>公众号名称</th>
                                    <th>文章数</th>
                                    <th>录入时间</th>
                                    <th>最后采集时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                $num = count($subs);
                                for ($l=0; $l<$num; $l++) {?>
                                    <tr>
                                        <th scope="row"><?php echo $l+1; ?></th>
                                        <td><?php echo $subs[$l]["sub_id"]; ?></td>
                                        <td><?php echo $subs[$l]["sub_name"]; ?></td>
                                        <td><?php echo $subs[$l]["sub_page_num"]; ?></td>
                                        <td><?php echo $subs[$l]["sub_input_time"]; ?></td>
                                        <td><?php echo $subs[$l]["sub_collect_time"]; ?></td>
                                        <td>
                                            <?php
                                            switch ($subs[$l]["sub_status"]){
                                                case 0:
                                                    ?>
                                                    <span class="badge badge-success">完成</span>
                                                    <?php
                                                    break;
                                                case 1:
                                                    ?>
                                                    <span class="badge badge-warning">进行中</span>
                                                    <?php
                                                    break;
                                                case 2:
                                                    ?>
                                                    <span class="badge badge-info">等待</span>
                                                    <?php
                                                    break;
                                                default:
                                                    ?>
                                                    <span class="badge badge-danger">异常</span>
                                                <?php
                                            }
                                            ?>
                                        </td>
                                        <td>
                                            <button type="button" class="btn btn-danger btn-rounded" onclick="window.location.href='/<?php echo site_url("subs") ?>/del/<?php echo $subs[$l]["id"]; ?>'">删除</button>
                                        </td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>

                        </div>
                        <br>
                        <div class="row">
                            <div class="col-sm-12 col-md-5">
                                <!--<div class="dataTables_info" role="status">
                                    Showing 1 to 10 of 57 entries
                                </div>-->
                            </div>
                            <div class="col-sm-12 col-md-7">
                                <div class="dataTables_paginate paging_simple_numbers">
                                    <ul class="pagination">
                                        <?php echo $this->pagination->create_links(); ?>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade modal-create-subscription" tabindex="-1" role="dialog"
     aria-labelledby="添加公众号" aria-hidden="true" style="display: none;">
    <form action="/<?php echo site_url("subs/create"); ?>" method="post">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加公众号</h5>
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">×</button>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label>公众号ID</label>
                        <input type="text" name="sub_id" class="form-control form-control-lg" required>
                    </div>
                    <div class="form-group">
                        <label>公众号名称(可选)</label>
                        <input type="text" name="sub_name" class="form-control">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-common">添加</button>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </form>
</div>